home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Mac OS USB DDK_v1.0.1 / USB.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-03  |  31.2 KB  |  1,138 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        USB.h
  3.  
  4.      Contains:    Public API for USB Services Library (and associated components)
  5.  
  6.      Version:    
  7.  
  8. */
  9. #ifndef __USB__
  10. #define __USB__
  11.  
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #ifndef __NAMEREGISTRY__
  16. #include <NameRegistry.h>
  17. #endif
  18. #ifndef __CODEFRAGMENTS__
  19. #include <CodeFragments.h>
  20. #endif
  21. #ifndef __DEVICES__
  22. #include <Devices.h>
  23. #endif
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. /* ************* Constants ************* */
  48.  
  49. enum {
  50.     kUSBNoErr                    = 0,
  51.     kUSBNoTran                    = 0,
  52.     kUSBNoDelay                    = 0,
  53.     kUSBPending                    = 1,                            /* */
  54.                                                                 /* USB assigned error numbers in range -6900 .. -6999 */
  55.     kUSBBaseError                = -7000,                        /* */
  56.                                                                 /* USB Services Errors */
  57.     kUSBInternalErr                = -6999,                        /* Internal error */
  58.     kUSBUnknownDeviceErr        = -6998,                        /*  device ref not recognised */
  59.     kUSBUnknownPipeErr            = -6997,                        /*  Pipe ref not recognised */
  60.     kUSBTooManyPipesErr            = -6996,                        /*  Too many pipes */
  61.     kUSBIncorrectTypeErr        = -6995,                        /*  Incorrect type */
  62.     kUSBRqErr                    = -6994,                        /*  Request error */
  63.     kUSBUnknownRequestErr        = -6993,                        /*  Unknown request */
  64.     kUSBTooManyTransactionsErr    = -6992,                        /*  Too many transactions */
  65.     kUSBAlreadyOpenErr            = -6991,                        /*  Already open */
  66.     kUSBNoDeviceErr                = -6990,                        /*  No device */
  67.     kUSBDeviceErr                = -6989,                        /*  Device error */
  68.     kUSBOutOfMemoryErr            = -6988,                        /*  Out of memory */
  69.     kUSBNotFound                = -6987,                        /*  Not found */
  70.     kUSBPBVersionError            = -6986,                        /*  Wrong pbVersion */
  71.     kUSBPBLengthError            = -6985,                        /*  pbLength too small */
  72.     kUSBCompletionError            = -6984,                        /*  no completion routine specified */
  73.     kUSBFlagsError                = -6983,                        /*  Unused flags not zeroed */
  74.     kUSBAbortedError            = -6982,                        /*  Pipe aborted */
  75.     kUSBNoBandwidthError        = -6981,                        /*  Not enough bandwidth available */
  76.     kUSBPipeIdleError            = -6980,                        /*  Pipe is Idle, it will not accept transactions */
  77.     kUSBPipeStalledError        = -6979,                        /*  Pipe has stalled, error needs to be cleared */
  78.     kUSBUnknownInterfaceErr        = -6978,                        /*  Interface ref not recognised */
  79.     kUSBDeviceBusy                = -6977,                        /*  Device is already being configured */
  80.     kUSBDevicePowerProblem        = -6976,                        /*  Device has a power problem */
  81.                                                                 /* */
  82.                                                                 /* USB Manager Errors */
  83.     kUSBBadDispatchTable        = -6950,                        /* Improper driver dispatch table */
  84.     kUSBUnknownNotification        = -6949,                        /* Notification type not defined */
  85.     kUSBQueueFull                = -6948,                        /* Internal queue maxxed */
  86.                                                                 /* */
  87.                                                                 /* Hardware Errors */
  88.                                                                 /* Note pipe stalls are communication */
  89.                                                                 /* errors. The affected pipe can not */
  90.                                                                 /* be used until USBClearPipeStallByReference  */
  91.                                                                 /* is used */
  92.                                                                 /* kUSBEndpointStallErr is returned in */
  93.                                                                 /* response to a stall handshake */
  94.                                                                 /* from a device. The device has to be */
  95.                                                                 /* cleared before a USBClearPipeStallByReference */
  96.                                                                 /* can be used */
  97.     kUSBLinkErr                    = -6916,
  98.     kUSBCRCErr                    = -6915,                        /*  Pipe stall, bad CRC */
  99.     kUSBBitstufErr                = -6914,                        /*  Pipe stall, bitstuffing */
  100.     kUSBDataToggleErr            = -6913,                        /*  Pipe stall, Bad data toggle */
  101.     kUSBEndpointStallErr        = -6912,                        /*  Device didn't understand */
  102.     kUSBNotRespondingErr        = -6911,                        /*  Pipe stall, No device, device hung */
  103.     kUSBPIDCheckErr                = -6910,                        /*  Pipe stall, PID CRC error */
  104.     kUSBWrongPIDErr                = -6909,                        /*  Pipe stall, Bad or wrong PID */
  105.     kUSBOverRunErr                = -6908,                        /*  Packet too large or more data than buffer */
  106.     kUSBUnderRunErr                = -6907,                        /*  Less data than buffer */
  107.     kUSBRes1Err                    = -6906,
  108.     kUSBRes2Err                    = -6905,
  109.     kUSBBufOvrRunErr            = -6904,                        /*  Host hardware failure on data in, PCI busy? */
  110.     kUSBBufUnderRunErr            = -6903,                        /*  Host hardware failure on data out, PCI busy? */
  111.     kUSBNotSent1Err                = -6902,                        /*  Transaction not sent */
  112.     kUSBNotSent2Err                = -6901                            /*  Transaction not sent */
  113. };
  114.  
  115.  
  116. enum {
  117.                                                                 /* Flags */
  118.     kUSBTaskTimeFlag            = 1
  119. };
  120.  
  121.  
  122. /* ************* types ************* */
  123.  
  124. typedef SInt32                             USBReference;
  125. typedef USBReference                     USBDeviceRef;
  126. typedef USBReference                     USBInterfaceRef;
  127. typedef USBReference                     USBPipeRef;
  128. typedef USBReference                     USBBusRef;
  129. typedef UInt32                             USBPipeState;
  130. typedef UInt32                             USBCount;
  131. typedef UInt32                             USBFlags;
  132. typedef UInt8                             USBRequest;
  133. typedef UInt8                             USBDirection;
  134. typedef UInt8                             USBRqRecipient;
  135. typedef UInt8                             USBRqType;
  136. typedef UInt16                             USBRqIndex;
  137. typedef UInt16                             USBRqValue;
  138. typedef struct USBPB                     USBPB;
  139. typedef CALLBACK_API_C( void , USBCompletion )(USBPB *pb);
  140.  
  141. struct USBPB {
  142.  
  143.     void *                            qlink;
  144.     UInt16                             qType;
  145.     UInt16                             pbLength;
  146.     UInt16                             pbVersion;
  147.     UInt16                             reserved1;
  148.     UInt32                             reserved2;
  149.  
  150.     OSStatus                         usbStatus;
  151.     USBCompletion                     usbCompletion;
  152.     UInt32                             usbRefcon;
  153.  
  154.     USBReference                     usbReference;
  155.  
  156.     void *                            usbBuffer;
  157.     USBCount                         usbReqCount;
  158.     USBCount                         usbActCount;
  159.  
  160.     USBFlags                         usbFlags;
  161.  
  162.     UInt8                             usbBMRequestType;
  163.     UInt8                             usbBRequest;
  164.     USBRqValue                         usbWValue;
  165.     USBRqIndex                         usbWIndex;
  166.     UInt16                             reserved4;
  167.  
  168.     UInt32                             usbFrame;                    /* reserved for future use */
  169.  
  170.     UInt8                             usbClassType;
  171.     UInt8                             usbSubclass;
  172.     UInt8                             usbProtocol;
  173.     UInt8                             usbOther;
  174.  
  175.     UInt32                             reserved6;
  176.     UInt16                             reserved7;
  177.     UInt16                             reserved8;
  178.  
  179. };
  180.  
  181.  
  182.  
  183. struct uslReq {
  184.     USBDirection                     usbDirection;
  185.     USBRqType                         usbType;
  186.     USBRqRecipient                     usbRecipient;
  187.     USBRequest                         usbRequest;
  188. };
  189. typedef struct uslReq                    uslReq;
  190.  
  191.  
  192. enum {
  193.                                                                 /* BT 13Jun98, bump up to v1.00 for final*/
  194.     kUSBCurrentPBVersion        = 0x0100                        /* v1.00*/
  195. };
  196.  
  197.  
  198.  
  199.  
  200. #define kUSBNoCallBack ((void *)-1L)
  201.  
  202.  
  203. typedef UInt8                             bcdUSB;
  204.  
  205. enum {
  206.     kUSBControl                    = 0,
  207.     kUSBIsoc                    = 1,
  208.     kUSBBulk                    = 2,
  209.     kUSBInterrupt                = 3,
  210.     kUSBAnyType                    = 0xFF
  211. };
  212.  
  213. /* endpoint type */
  214.  
  215. enum {
  216.     kUSBOut                        = 0,
  217.     kUSBIn                        = 1,
  218.     kUSBNone                    = 2,
  219.     kUSBAnyDirn                    = 3
  220. };
  221.  
  222. /*USBDirection*/
  223.  
  224. enum {
  225.     kUSBStandard                = 0,
  226.     kUSBClass                    = 1,
  227.     kUSBVendor                    = 2
  228. };
  229.  
  230. /*USBRqType*/
  231.  
  232. enum {
  233.     kUSBDevice                    = 0,
  234.     kUSBInterface                = 1,
  235.     kUSBEndpoint                = 2,
  236.     kUSBOther                    = 3
  237. };
  238.  
  239. /*USBRqRecipient*/
  240.  
  241. enum {
  242.     kUSBRqGetStatus                = 0,
  243.     kUSBRqClearFeature            = 1,
  244.     kUSBRqReserved1                = 2,
  245.     kUSBRqSetFeature            = 3,
  246.     kUSBRqReserved2                = 4,
  247.     kUSBRqSetAddress            = 5,
  248.     kUSBRqGetDescriptor            = 6,
  249.     kUSBRqSetDescriptor            = 7,
  250.     kUSBRqGetConfig                = 8,
  251.     kUSBRqSetConfig                = 9,
  252.     kUSBRqGetInterface            = 10,
  253.     kUSBRqSetInterface            = 11,
  254.     kUSBRqSyncFrame                = 12
  255. };
  256.  
  257. /*USBRequest*/
  258.  
  259.  
  260. enum {
  261.     kUSBDeviceDesc                = 1,
  262.     kUSBConfDesc                = 2,
  263.     kUSBStringDesc                = 3,
  264.     kUSBInterfaceDesc            = 4,
  265.     kUSBEndpointDesc            = 5,
  266.     kUSBHIDDesc                    = 0x21,
  267.     kUSBReportDesc                = 0x22,
  268.     kUSBPhysicalDesc            = 0x23,
  269.     kUSBHUBDesc                    = 0x29
  270. };
  271.  
  272. /* descriptorType */
  273.  
  274. enum {
  275.     kUSBActive                    = 0,                            /* Pipe can accept new transactions*/
  276.     kUSBIdle                    = 1,                            /* Pipe will not accept new transactions*/
  277.     kUSBStalled                    = 2                                /* An error occured on the pipe*/
  278. };
  279.  
  280.  
  281. enum {
  282.     kUSB100mAAvailable            = 50,
  283.     kUSB500mAAvailable            = 250,
  284.     kUSB100mA                    = 50,
  285.     kUSBAtrBusPowered            = 0x80,
  286.     kUSBAtrSelfPowered            = 0x40,
  287.     kUSBAtrRemoteWakeup            = 0x20
  288. };
  289.  
  290.  
  291. enum {
  292.     kUSBRel10                    = 0x0100
  293. };
  294.  
  295. #define USB_CONSTANT16(x)    ((((x) >> 8) & 0x0ff) | ((x & 0xff) << 8))
  296.  
  297. struct USBDeviceDescriptor {
  298.     UInt8                             length;
  299.     UInt8                             descType;
  300.     UInt16                             usbRel;
  301.     UInt8                             deviceClass;
  302.     UInt8                             deviceSubClass;
  303.     UInt8                             protocol;
  304.     UInt8                             maxPacketSize;
  305.     UInt16                             vendor;
  306.     UInt16                             product;
  307.     UInt16                             devRel;
  308.     UInt8                             manuIdx;
  309.     UInt8                             prodIdx;
  310.     UInt8                             serialIdx;
  311.     UInt8                             numConf;
  312.     UInt16                             descEnd;                    /* was "end", but this is reserved in some languages*/
  313. };
  314. typedef struct USBDeviceDescriptor        USBDeviceDescriptor;
  315. #ifndef OLDCLASSNAMES
  316. #ifndef __cplusplus
  317. #define class deviceClass
  318. #define subClass deviceSubClass
  319. #endif
  320. #endif
  321. typedef USBDeviceDescriptor *            USBDeviceDescriptorPtr;
  322.  
  323. struct USBDescriptorHeader {
  324.     UInt8                             length;
  325.     UInt8                             descriptorType;
  326. };
  327. typedef struct USBDescriptorHeader        USBDescriptorHeader;
  328. typedef USBDescriptorHeader *            USBDescriptorHeaderPtr;
  329.  
  330. struct USBConfigurationDescriptor {
  331.     UInt8                             length;
  332.     UInt8                             descriptorType;
  333.     UInt16                             totalLength;
  334.     UInt8                             numInterfaces;
  335.     UInt8                             configValue;
  336.     UInt8                             configStrIndex;
  337.     UInt8                             attributes;
  338.     UInt8                             maxPower;
  339. };
  340. typedef struct USBConfigurationDescriptor USBConfigurationDescriptor;
  341. typedef USBConfigurationDescriptor *    USBConfigurationDescriptorPtr;
  342.  
  343. struct USBInterfaceDescriptor {
  344.     UInt8                             length;
  345.     UInt8                             descriptorType;
  346.     UInt8                             interfaceNumber;
  347.     UInt8                             alternateSetting;
  348.     UInt8                             numEndpoints;
  349.     UInt8                             interfaceClass;
  350.     UInt8                             interfaceSubClass;
  351.     UInt8                             interfaceProtocol;
  352.     UInt8                             interfaceStrIndex;
  353. };
  354. typedef struct USBInterfaceDescriptor    USBInterfaceDescriptor;
  355. typedef USBInterfaceDescriptor *        USBInterfaceDescriptorPtr;
  356.  
  357. struct USBEndPointDescriptor {
  358.     UInt8                             length;
  359.     UInt8                             descriptorType;
  360.     UInt8                             endpointAddress;
  361.     UInt8                             attributes;
  362.     UInt16                             maxPacketSize;
  363.     UInt8                             interval;
  364. };
  365. typedef struct USBEndPointDescriptor    USBEndPointDescriptor;
  366. typedef USBEndPointDescriptor *            USBEndPointDescriptorPtr;
  367.  
  368. struct USBHIDDescriptor {
  369.     UInt8                             descLen;
  370.     UInt8                             descType;
  371.     UInt16                             descVersNum;
  372.     UInt8                             hidCountryCode;
  373.     UInt8                             hidNumDescriptors;
  374.     UInt8                             hidDescriptorType;
  375.     UInt8                             hidDescriptorLengthLo;        /* can't make this a single 16bit value or the compiler will add a filler byte*/
  376.     UInt8                             hidDescriptorLengthHi;
  377. };
  378. typedef struct USBHIDDescriptor            USBHIDDescriptor;
  379. typedef USBHIDDescriptor *                USBHIDDescriptorPtr;
  380.  
  381. struct USBHIDReportDesc {
  382.     UInt8                             hidDescriptorType;
  383.     UInt8                             hidDescriptorLengthLo;        /* can't make this a single 16bit value or the compiler will add a filler byte*/
  384.     UInt8                             hidDescriptorLengthHi;
  385. };
  386. typedef struct USBHIDReportDesc            USBHIDReportDesc;
  387. typedef USBHIDReportDesc *                USBHIDReportDescPtr;
  388.  
  389. struct USBHubPortStatus {
  390.     UInt16                             portFlags;                    /* Port status flags */
  391.     UInt16                             portChangeFlags;            /* Port changed flags */
  392. };
  393. typedef struct USBHubPortStatus            USBHubPortStatus;
  394. typedef USBHubPortStatus *                USBHubPortStatusPtr;
  395. /* ********* ProtoTypes *************** */
  396. /* For dealing with endianisms */
  397. EXTERN_API_C( UInt16 )
  398. HostToUSBWord                    (UInt16                 value);
  399.  
  400. EXTERN_API_C( UInt16 )
  401. USBToHostWord                    (UInt16                 value);
  402.  
  403. /* Main prototypes */
  404. /* Transfer commands */
  405. EXTERN_API_C( OSStatus )
  406. USBDeviceRequest                (USBPB *                pb);
  407.  
  408. EXTERN_API_C( OSStatus )
  409. USBOpenPipe                        (USBPB *                pb);
  410.  
  411. EXTERN_API_C( OSStatus )
  412. USBClosePipe                    (USBPB *                pb);
  413.  
  414. EXTERN_API_C( OSStatus )
  415. USBBulkWrite                    (USBPB *                pb);
  416.  
  417. EXTERN_API_C( OSStatus )
  418. USBBulkRead                        (USBPB *                pb);
  419.  
  420. EXTERN_API_C( OSStatus )
  421. USBIntRead                        (USBPB *                pb);
  422.  
  423. /* Pipe state control */
  424. EXTERN_API_C( OSStatus )
  425. USBClearPipeStallByReference    (USBPipeRef             ref);
  426.  
  427. EXTERN_API_C( OSStatus )
  428. USBAbortPipeByReference            (USBReference             ref);
  429.  
  430. EXTERN_API_C( OSStatus )
  431. USBResetPipeByReference            (USBReference             ref);
  432.  
  433. EXTERN_API_C( OSStatus )
  434. USBSetPipeIdleByReference        (USBPipeRef             ref);
  435.  
  436. EXTERN_API_C( OSStatus )
  437. USBSetPipeActiveByReference        (USBPipeRef             ref);
  438.  
  439. EXTERN_API_C( OSStatus )
  440. USBClosePipeByReference            (USBPipeRef             ref);
  441.  
  442. EXTERN_API_C( OSStatus )
  443. USBGetPipeStatusByReference        (USBReference             ref,
  444.                                  USBPipeState *            state);
  445.  
  446.  
  447. /* Configuration services */
  448. EXTERN_API_C( OSStatus )
  449. USBFindNextInterface            (USBPB *                pb);
  450.  
  451. EXTERN_API_C( OSStatus )
  452. USBOpenDevice                    (USBPB *                pb);
  453.  
  454. EXTERN_API_C( OSStatus )
  455. USBNewInterfaceRef                (USBPB *                pb);
  456.  
  457. EXTERN_API_C( OSStatus )
  458. USBDisposeInterfaceRef            (USBPB *                pb);
  459.  
  460. EXTERN_API_C( OSStatus )
  461. USBConfigureInterface            (USBPB *                pb);
  462.  
  463. EXTERN_API_C( OSStatus )
  464. USBFindNextPipe                    (USBPB *                pb);
  465.  
  466.  
  467. /* Dealing with descriptors. */
  468. /* Note most of this is temprorary */
  469. EXTERN_API_C( OSStatus )
  470. USBGetConfigurationDescriptor    (USBPB *                pb);
  471.  
  472. EXTERN_API_C( OSStatus )
  473. USBGetFullConfigurationDescriptor (USBPB *                pb);
  474.  
  475. EXTERN_API_C( OSStatus )
  476. USBFindNextEndpointDescriptorImmediate (USBPB *            pb);
  477.  
  478. EXTERN_API_C( OSStatus )
  479. USBFindNextInterfaceDescriptorImmediate (USBPB *        pb);
  480.  
  481. EXTERN_API_C( OSStatus )
  482. USBFindNextAssociatedDescriptor    (USBPB *                pb);
  483.  
  484.  
  485.  
  486. /* Utility functions */
  487. EXTERN_API_C( OSStatus )
  488. USBGetFrameNumberImmediate        (USBPB *                pb);
  489.  
  490. EXTERN_API_C( OSStatus )
  491. USBDelay                        (USBPB *                pb);
  492.  
  493. EXTERN_API_C( OSStatus )
  494. USBAllocMem                        (USBPB *                pb);
  495.  
  496. EXTERN_API_C( OSStatus )
  497. USBDeallocMem                    (USBPB *                pb);
  498.  
  499. /* Expert interface functions */
  500. EXTERN_API_C( OSStatus )
  501. USBExpertInstallInterfaceDriver    (USBDeviceRef             ref,
  502.                                  USBDeviceDescriptorPtr  desc,
  503.                                  USBInterfaceDescriptorPtr  interfacePtr,
  504.                                  USBReference             hubRef,
  505.                                  UInt32                 busPowerAvailable);
  506.  
  507. EXTERN_API_C( OSStatus )
  508. USBExpertRemoveInterfaceDriver    (USBDeviceRef             ref);
  509.  
  510. EXTERN_API_C( OSStatus )
  511. USBExpertInstallDeviceDriver    (USBDeviceRef             ref,
  512.                                  USBDeviceDescriptorPtr  desc,
  513.                                  USBReference             hubRef,
  514.                                  UInt32                 port,
  515.                                  UInt32                 busPowerAvailable);
  516.  
  517. EXTERN_API_C( OSStatus )
  518. USBExpertRemoveDeviceDriver        (USBDeviceRef             ref);
  519.  
  520. EXTERN_API_C( OSStatus )
  521. USBExpertStatus                    (USBDeviceRef             ref,
  522.                                  void *                    pointer,
  523.                                  UInt32                 value);
  524.  
  525. EXTERN_API_C( OSStatus )
  526. USBExpertFatalError                (USBDeviceRef             ref,
  527.                                  OSStatus                 status,
  528.                                  void *                    pointer,
  529.                                  UInt32                 value);
  530.  
  531. EXTERN_API_C( OSStatus )
  532. USBExpertNotify                    (void *                    note);
  533.  
  534. EXTERN_API_C( OSStatus )
  535. USBExpertSetDevicePowerStatus    (USBDeviceRef             ref,
  536.                                  UInt32                 reserved1,
  537.                                  UInt32                 reserved2,
  538.                                  UInt32                 powerStatus,
  539.                                  UInt32                 busPowerAvailable,
  540.                                  UInt32                 busPowerNeeded);
  541.  
  542.  
  543. enum {
  544.     kUSBDevicePower_PowerOK        = 0,
  545.     kUSBDevicePower_BusPowerInsufficient = 1,
  546.     kUSBDevicePower_BusPowerNotAllFeatures = 2,
  547.     kUSBDevicePower_SelfPowerInsufficient = 3,
  548.     kUSBDevicePower_SelfPowerNotAllFeatures = 4,
  549.     kUSBDevicePower_HubPortOk    = 5,
  550.     kUSBDevicePower_HubPortOverCurrent = 6,
  551.     kUSBDevicePower_BusPoweredHubOnLowPowerPort = 7,
  552.     kUSBDevicePower_BusPoweredHubToBusPoweredHub = 8,
  553.     kUSBDevicePower_Reserved3    = 9,
  554.     kUSBDevicePower_Reserved4    = 10
  555. };
  556.  
  557.  
  558.  
  559. /* For hubs only */
  560. EXTERN_API_C( OSStatus )
  561. USBHubAddDevice                    (USBPB *                pb);
  562.  
  563. EXTERN_API_C( OSStatus )
  564. USBHubConfigurePipeZero            (USBPB *                pb);
  565.  
  566. EXTERN_API_C( OSStatus )
  567. USBHubSetAddress                (USBPB *                pb);
  568.  
  569. EXTERN_API_C( OSStatus )
  570. USBHubDeviceRemoved                (USBPB *                pb);
  571.  
  572.  
  573. EXTERN_API_C( UInt8 )
  574. USBMakeBMRequestType            (UInt8                     direction,
  575.                                  UInt8                     reqtype,
  576.                                  UInt8                     recipient);
  577.  
  578. /* This not implemented until someone shows me a test case */
  579. /*OSStatus USBControlRequest(USBPB *pb);*/
  580.  
  581. enum {
  582.     kNoDeviceRef                = -1
  583. };
  584.  
  585. /* Expert Notification Types*/
  586.  
  587. typedef UInt8                             USBNotificationType;
  588.  
  589. enum {
  590.     kNotifyAddDevice            = 0x00,
  591.     kNotifyRemoveDevice            = 0x01,
  592.     kNotifyAddInterface            = 0x02,
  593.     kNotifyRemoveInterface        = 0x03,
  594.     kNotifyGetDeviceDescriptor    = 0x04,
  595.     kNotifyGetInterfaceDescriptor = 0x05,
  596.     kNotifyGetNextDeviceByClass    = 0x06,
  597.     kNotifyGetDriverConnectionID = 0x07,
  598.     kNotifyInstallDeviceNotification = 0x08,
  599.     kNotifyRemoveDeviceNotification = 0x09,
  600.     kNotifyDeviceRefToBusRef    = 0x0A,
  601.     kNotifyDriverBeingRemoved    = 0x0B,
  602.     kNotifyAnyEvent                = 0xFF,
  603.     kNotifyPowerState            = 0x17,
  604.     kNotifyStatus                = 0x18,
  605.     kNotifyFatalError            = 0x19,
  606.     kNotifyGetConnectionIDByClass = 0x1A
  607. };
  608.  
  609.  
  610. /*
  611.    Data structure passed to Expert with callback
  612.    The Expert's notification function rules with regard
  613.    to the struct passed in:
  614.         if (kNotifyRemoveDevice || kNotifyRemoveInterface)
  615.               Remove the driver corresponding to deviceRef.
  616.               data, info1, info2 are ignored.
  617.           if (kNotifyAddDevice)
  618.               data is a USBDeviceDescPtr.
  619.               deviceRef is already assigned.
  620.               info1 is the USBDeviceRef of the new device's parent hub.
  621.               info2 is the port # the device is plugged in to.
  622.           if (kNotifyAddInterface)
  623.               data is a USBInterfaceDescPtr.
  624.               deviceRef is already assigned.
  625.               info1 is the USBDeviceRef of the interface's parent device.
  626.               info2 is a pointer to the USBDeviceDescriptor of the device.
  627.           if (kNotifyRemoveInterface)
  628.               Remove the driver corresponding to deviceRef.
  629.               data, info1, info2 are ignored.
  630.           if (kNotifyGetDeviceDescriptor)
  631.               Retrieve the USBDeviceDescriptor corresponding to deviceRef.
  632.               data contains a pointer to a USBDeviceDescriptor.
  633.               info1 and info2 are ignored.
  634.           if (kNotifyGetInterfaceDescriptor)
  635.               Retrieve the USBInterfaceDescriptor corresponding to deviceRef.
  636.               data contains a pointer to a USBInterfaceDescriptor.
  637.               info1 and info2 are ignored.
  638.           if (kNotifyGetNextDeviceByClass)
  639.               Retrieve the next USBDeviceRef that matches the supplied
  640.               class and, optionally, subclass and protocol.
  641.               data contains the class, subclass and protocol munged into a UInt32.
  642.               info1 and info2 are ignored.
  643.           if (kNotifyGetDriverConnectionID)
  644.               retrieve the CFragConnectionID corresponding to deviceRef.
  645.               data is a pointer to a CFragConnectinID.
  646.           if (kNotifyGetConnectionIDByClass)
  647.               retrieve the CFragConnectionID corresponding to deviceRef (disguised
  648.             as the search bits).
  649.               data is a pointer to a CFragConnectinID.
  650. */
  651.  
  652. struct ExpertNotificationData {
  653.     USBNotificationType             notification;
  654.     UInt8                             filler[1];                    /* unused due to 2-byte 68k alignment*/
  655.     USBDeviceRef *                    deviceRef;
  656.     UInt32                             busPowerAvailable;
  657.     void *                            data;
  658.     UInt32                             info1;
  659.     UInt32                             info2;
  660. };
  661. typedef struct ExpertNotificationData    ExpertNotificationData;
  662. typedef ExpertNotificationData *        ExpertNotificationDataPtr;
  663. /* Definition of function pointer passed in ExpertEntryProc*/
  664. typedef CALLBACK_API_C( OSStatus , ExpertNotificationProcPtr )(ExpertNotificationDataPtr pNotificationData);
  665. /* Definition of expert's callback installation function*/
  666. typedef CALLBACK_API_C( OSStatus , ExpertEntryProcPtr )(ExpertNotificationProcPtr pExpertNotify);
  667. /* Device Notification Callback Routine*/
  668. typedef CALLBACK_API_C( void , USBDeviceNotificationCallbackProcPtr )(void *pb);
  669. /* Device Notification Parameter Block*/
  670.  
  671. struct USBDeviceNotificationParameterBlock {
  672.     UInt16                             pbLength;
  673.     UInt16                             pbVersion;
  674.     USBNotificationType             usbDeviceNotification;
  675.     UInt8                             reserved1[1];                /* needed because of 2-byte 68k alignment*/
  676.     USBDeviceRef                     usbDeviceRef;
  677.     SInt16                             usbClass;
  678.     SInt16                             usbSubClass;
  679.     SInt16                             usbProtocol;
  680.     SInt16                             usbVendor;
  681.     SInt16                             usbProduct;
  682.     OSStatus                         result;
  683.     UInt32                             token;
  684.     USBDeviceNotificationCallbackProcPtr  callback;
  685.     UInt32                             refcon;
  686. };
  687. typedef struct USBDeviceNotificationParameterBlock USBDeviceNotificationParameterBlock;
  688. /* Forward declaration*/
  689. typedef USBDeviceNotificationParameterBlock * USBDeviceNotificationParameterBlockPtr;
  690. /* Public Functions*/
  691. EXTERN_API_C( OSStatus )
  692. USBGetNextDeviceByClass            (USBDeviceRef *            deviceRef,
  693.                                  CFragConnectionID *    connID,
  694.                                  UInt16                 deviceClass,
  695.                                  UInt16                 deviceSubClass,
  696.                                  UInt16                 deviceProtocol);
  697.  
  698. EXTERN_API_C( OSStatus )
  699. USBGetDeviceDescriptor            (USBDeviceRef *            deviceRef,
  700.                                  USBDeviceDescriptor *    deviceDescriptor,
  701.                                  UInt32                 size);
  702.  
  703. EXTERN_API_C( OSStatus )
  704. USBGetInterfaceDescriptor        (USBInterfaceRef *        interfaceRef,
  705.                                  USBInterfaceDescriptor * interfaceDescriptor,
  706.                                  UInt32                 size);
  707.  
  708. EXTERN_API_C( OSStatus )
  709. USBGetDriverConnectionID        (USBDeviceRef *            deviceRef,
  710.                                  CFragConnectionID *    connID);
  711.  
  712. EXTERN_API_C( void )
  713. USBInstallDeviceNotification    (USBDeviceNotificationParameterBlock * pb);
  714.  
  715. EXTERN_API_C( OSStatus )
  716. USBRemoveDeviceNotification        (UInt32                 token);
  717.  
  718. EXTERN_API_C( OSStatus )
  719. USBDeviceRefToBusRef            (USBDeviceRef *            deviceRef,
  720.                                  USBBusRef *            busRef);
  721.  
  722. typedef CALLBACK_API_C( void , HIDInterruptProcPtr )(UInt32 refcon, void *theData);
  723. /* HID Install Interrupt prototype*/
  724. typedef CALLBACK_API_C( OSStatus , USBHIDInstallInterruptProcPtr )(HIDInterruptProcPtr pInterruptProc, UInt32 refcon);
  725. /* HID Poll Device prototype*/
  726. typedef CALLBACK_API_C( OSStatus , USBHIDPollDeviceProcPtr )(void );
  727. /* HID Control Device prototype*/
  728. typedef CALLBACK_API_C( OSStatus , USBHIDControlDeviceProcPtr )(UInt32 theControlSelector, void *theControlData);
  729. /* HID Get Device Info prototype*/
  730. typedef CALLBACK_API_C( OSStatus , USBHIDGetDeviceInfoProcPtr )(UInt32 theInfoSelector, void *theInfo);
  731. /* HID Enter Polled Mode prototype*/
  732. typedef CALLBACK_API_C( OSStatus , USBHIDEnterPolledModeProcPtr )(void );
  733. /* HID Exit Polled Mode prototype*/
  734. typedef CALLBACK_API_C( OSStatus , USBHIDExitPolledModeProcPtr )(void );
  735.  
  736. struct USBHIDModuleDispatchTable {
  737.     UInt32                             hidDispatchVersion;
  738.     USBHIDInstallInterruptProcPtr     pUSBHIDInstallInterrupt;
  739.     USBHIDPollDeviceProcPtr         pUSBHIDPollDevice;
  740.     USBHIDControlDeviceProcPtr         pUSBHIDControlDevice;
  741.     USBHIDGetDeviceInfoProcPtr         pUSBHIDGetDeviceInfo;
  742.     USBHIDEnterPolledModeProcPtr     pUSBHIDEnterPolledMode;
  743.     USBHIDExitPolledModeProcPtr     pUSBHIDExitPolledMode;
  744. };
  745. typedef struct USBHIDModuleDispatchTable USBHIDModuleDispatchTable;
  746. typedef USBHIDModuleDispatchTable *        USBHIDModuleDispatchTablePtr;
  747. /*    Prototypes Tue, Mar 17, 1998 4:54:30 PM    */
  748. EXTERN_API_C( OSStatus )
  749. USBHIDInstallInterrupt            (HIDInterruptProcPtr     HIDInterruptFunction,
  750.                                  UInt32                 refcon);
  751.  
  752. EXTERN_API_C( OSStatus )
  753. USBHIDPollDevice                (void);
  754.  
  755. EXTERN_API_C( OSStatus )
  756. USBHIDControlDevice                (UInt32                 theControlSelector,
  757.                                  void *                    theControlData);
  758.  
  759. EXTERN_API_C( OSStatus )
  760. USBHIDGetDeviceInfo                (UInt32                 theInfoSelector,
  761.                                  void *                    theInfo);
  762.  
  763. EXTERN_API_C( OSStatus )
  764. USBHIDEnterPolledMode            (void);
  765.  
  766. EXTERN_API_C( OSStatus )
  767. USBHIDExitPolledMode            (void);
  768.  
  769. EXTERN_API_C( void )
  770. HIDNotification                    (UInt32                 devicetype,
  771.                                  UInt8                     NewHIDData[],
  772.                                  UInt8                     OldHIDData[]);
  773.  
  774.  
  775. enum {
  776.     kHIDRqGetReport                = 1,
  777.     kHIDRqGetIdle                = 2,
  778.     kHIDRqGetProtocol            = 3,
  779.     kHIDRqSetReport                = 9,
  780.     kHIDRqSetIdle                = 10,
  781.     kHIDRqSetProtocol            = 11
  782. };
  783.  
  784.  
  785. enum {
  786.     kHIDRtInputReport            = 1,
  787.     kHIDRtOutputReport            = 2,
  788.     kHIDRtFeatureReport            = 3
  789. };
  790.  
  791.  
  792. enum {
  793.     kHIDBootProtocolValue        = 0,
  794.     kHIDReportProtocolValue        = 1
  795. };
  796.  
  797.  
  798. enum {
  799.     kHIDKeyboardInterfaceProtocol = 1,
  800.     kHIDMouseInterfaceProtocol    = 2
  801. };
  802.  
  803.  
  804. enum {
  805.     kHIDSetLEDStateByBits        = 1,
  806.     kHIDSetLEDStateByBitMask    = 1,
  807.     kHIDSetLEDStateByIDNumber    = 2,
  808.     kHIDRemoveInterruptHandler    = 3,
  809.     kHIDEnableDemoMode            = 4,
  810.     kHIDDisableDemoMode            = 5
  811. };
  812.  
  813.  
  814. enum {
  815.     kHIDGetLEDStateByBits        = 1,                            /* not supported in 1.0 of keyboard module*/
  816.     kHIDGetLEDStateByBitMask    = 1,                            /* not supported in 1.0 of keyboard module*/
  817.     kHIDGetLEDStateByIDNumber    = 2,
  818.     kHIDGetDeviceCountryCode    = 3,                            /* not supported in 1.0 HID modules*/
  819.     kHIDGetDeviceUnitsPerInch    = 4,                            /* only supported in mouse HID module*/
  820.     kHIDGetInterruptHandler        = 5,
  821.     kHIDGetCurrentKeys            = 6,                            /* only supported in keyboard HID module*/
  822.     kHIDGetInterruptRefcon        = 7,
  823.     kHIDGetVenderID                = 8,
  824.     kHIDGetProductID            = 9
  825. };
  826.  
  827.  
  828.  
  829. enum {
  830.     kNumLockLED                    = 0,
  831.     kCapsLockLED                = 1,
  832.     kScrollLockLED                = 2,
  833.     kComposeLED                    = 3,
  834.     kKanaLED                    = 4
  835. };
  836.  
  837.  
  838. enum {
  839.     kNumLockLEDMask                = 1 << kNumLockLED,
  840.     kCapsLockLEDMask            = 1 << kCapsLockLED,
  841.     kScrollLockLEDMask            = 1 << kScrollLockLED,
  842.     kComposeLEDMask                = 1 << kComposeLED,
  843.     kKanaLEDMask                = 1 << kKanaLED
  844. };
  845.  
  846.  
  847. enum {
  848.     kUSBCapsLockKey                = 0x39,
  849.     kUSBNumLockKey                = 0x53,
  850.     kUSBScrollLockKey            = 0x47
  851. };
  852.  
  853.  
  854. struct USBMouseData {
  855.     UInt16                             buttons;
  856.     SInt16                             XDelta;
  857.     SInt16                             YDelta;
  858. };
  859. typedef struct USBMouseData                USBMouseData;
  860. typedef USBMouseData *                    USBMouseDataPtr;
  861.  
  862. struct USBKeyboardData {
  863.     UInt16                             keycount;
  864.     UInt16                             usbkeycode[32];
  865. };
  866. typedef struct USBKeyboardData            USBKeyboardData;
  867. typedef USBKeyboardData *                USBKeyboardDataPtr;
  868.  
  869. union USBHIDData {
  870.     USBKeyboardData                 kbd;
  871.     USBMouseData                     mouse;
  872. };
  873. typedef union USBHIDData                USBHIDData;
  874. typedef USBHIDData *                    USBHIDDataPtr;
  875. EXTERN_API_C( void )
  876. StartCompoundClassDriver        (USBDeviceRef             device,
  877.                                  UInt16                 classID,
  878.                                  UInt16                 subClass);
  879.  
  880.  
  881. enum {
  882.     kUSBCompositeClass            = 0,
  883.     kUSBAudioClass                = 1,
  884.     kUSBCommClass                = 2,
  885.     kUSBHIDClass                = 3,
  886.     kUSBDisplayClass            = 4,
  887.     kUSBPrintingClass            = 7,
  888.     kUSBMassStorageClass        = 8,
  889.     kUSBHubClass                = 9,
  890.     kUSBDataClass                = 10,
  891.     kUSBVenderSpecificClass        = 0xFF
  892. };
  893.  
  894.  
  895. enum {
  896.     kUSBCompositeSubClass        = 0,
  897.     kUSBHubSubClass                = 1
  898. };
  899.  
  900.  
  901. enum {
  902.     kUSBHIDInterfaceClass        = 0x03
  903. };
  904.  
  905.  
  906. enum {
  907.     kUSBNoInterfaceSubClass        = 0x00,
  908.     kUSBBootInterfaceSubClass    = 0x01
  909. };
  910.  
  911.  
  912. enum {
  913.     kUSBNoInterfaceProtocol        = 0x00,
  914.     kUSBKeyboardInterfaceProtocol = 0x01,
  915.     kUSBMouseInterfaceProtocol    = 0x02
  916. };
  917.  
  918.  
  919.  
  920.  
  921. enum {
  922.     kServiceCategoryUSB            = FOUR_CHAR_CODE('usb ')        /* USB*/
  923. };
  924.  
  925. /* SOMETHING NEEDS TO BE DONE WITH THIS - */
  926.  
  927. enum {
  928.     kUSBTypeIsHub                = FOUR_CHAR_CODE('hubd'),        /* Hub*/
  929.     kUSBTypeIsHID                = FOUR_CHAR_CODE('HIDd'),        /* Human Interface Device*/
  930.     kUSBTypeIsDisplay            = FOUR_CHAR_CODE('disp'),        /* Display */
  931.     kUSBTypeIsModem                = FOUR_CHAR_CODE('modm')        /* Modem*/
  932. };
  933.  
  934.  
  935. enum {
  936.     kUSBDriverFileType            = FOUR_CHAR_CODE('ndrv'),
  937.     kUSBDriverRsrcType            = FOUR_CHAR_CODE('usbd'),
  938.     kUSBShimRsrcType            = FOUR_CHAR_CODE('usbs')
  939. };
  940.  
  941.  
  942. enum {
  943.     kTheUSBDriverDescriptionSignature = FOUR_CHAR_CODE('usbd')
  944. };
  945.  
  946.  
  947. enum {
  948.     kInitialUSBDriverDescriptor    = 0
  949. };
  950.  
  951.  
  952.  
  953. typedef UInt32                             USBDriverDescVersion;
  954. /*  Driver Loading Options*/
  955. typedef UInt32                             USBDriverLoadingOptions;
  956.  
  957. enum {
  958.     kUSBDoNotMatchGenericDevice    = 0x00000001,                    /* Driver's VendorID must match Device's VendorID*/
  959.     kUSBDoNotMatchInterface        = 0x00000002,                    /* Do not load this driver as an interface driver.*/
  960.     kUSBProtocolMustMatch        = 0x00000004                    /* Do not load this driver if protocol field doesn't match.*/
  961. };
  962.  
  963.  
  964. enum {
  965.     kClassDriverPluginVersion    = 0x00010000
  966. };
  967.  
  968.  
  969.  
  970.  
  971. struct USBDeviceInfo {
  972.     UInt16                             usbVendorID;                /* USB Vendor ID*/
  973.     UInt16                             usbProductID;                /* USB Product ID.*/
  974.     UInt16                             usbDeviceReleaseNumber;        /* Release Number of Device*/
  975.     UInt16                             usbDeviceProtocol;            /* Protocol Info.*/
  976. };
  977. typedef struct USBDeviceInfo            USBDeviceInfo;
  978. typedef USBDeviceInfo *                    USBDeviceInfoPtr;
  979.  
  980. struct USBInterfaceInfo {
  981.     UInt8                             usbConfigValue;                /* Configuration Value*/
  982.     UInt8                             usbInterfaceNum;            /* Interface Number*/
  983.     UInt8                             usbInterfaceClass;            /* Interface Class*/
  984.     UInt8                             usbInterfaceSubClass;        /* Interface SubClass*/
  985.     UInt8                             usbInterfaceProtocol;        /* Interface Protocol*/
  986. };
  987. typedef struct USBInterfaceInfo            USBInterfaceInfo;
  988. typedef USBInterfaceInfo *                USBInterfaceInfoPtr;
  989.  
  990. struct USBDriverType {
  991.     Str31                             nameInfoStr;                /* Driver's name when loading into the Name Registry.*/
  992.     UInt8                             usbDriverClass;                /* USB Class this driver belongs to.*/
  993.     UInt8                             usbDriverSubClass;            /* Module type*/
  994.     NumVersion                         usbDriverVersion;            /* Class driver version number.*/
  995. };
  996. typedef struct USBDriverType            USBDriverType;
  997. typedef USBDriverType *                    USBDriverTypePtr;
  998.  
  999. struct USBDriverDescription {
  1000.     OSType                             usbDriverDescSignature;        /* Signature field of this structure.*/
  1001.     USBDriverDescVersion             usbDriverDescVersion;        /* Version of this data structure.*/
  1002.     USBDeviceInfo                     usbDeviceInfo;                /* Product & Vendor Info*/
  1003.     USBInterfaceInfo                 usbInterfaceInfo;            /* Interface info*/
  1004.     USBDriverType                     usbDriverType;                /* Driver Info.*/
  1005.     USBDriverLoadingOptions         usbDriverLoadingOptions;    /* Options for class driver loading.*/
  1006. };
  1007. typedef struct USBDriverDescription        USBDriverDescription;
  1008. typedef USBDriverDescription *            USBDriverDescriptionPtr;
  1009. /*
  1010.    Dispatch Table
  1011.    Definition of class driver's HW Validation proc.
  1012. */
  1013. typedef CALLBACK_API_C( OSStatus , USBDValidateHWProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  1014. /*
  1015.    Definition of class driver's device initialization proc.
  1016.    Called if the driver is being loaded for a device
  1017. */
  1018. typedef CALLBACK_API_C( OSStatus , USBDInitializeDeviceProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  1019. /* Definition of class driver's interface initialization proc.*/
  1020. typedef CALLBACK_API_C( OSStatus , USBDInitializeInterfaceProcPtr )(UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDevice, USBInterfaceRef interfaceRef);
  1021. /* Definition of class driver's finalization proc.*/
  1022. typedef CALLBACK_API_C( OSStatus , USBDFinalizeProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  1023.  
  1024. typedef UInt32                             USBDeviceNotification;
  1025.  
  1026. enum {
  1027.     kDeviceAdded                = 0x00000001
  1028. };
  1029.  
  1030. /* Definition of driver's notificatipn proc.      // NOTE: NEED TO DEFINE SOME NOTIFICATION CONSTANTS*/
  1031. typedef CALLBACK_API_C( OSStatus , USBDDriverNotifyProcPtr )(USBDeviceNotification notification, void *pointer);
  1032.  
  1033. struct USBClassDriverPluginDispatchTable {
  1034.     UInt32                             pluginVersion;
  1035.     USBDValidateHWProcPtr             validateHWProc;                /* Proc for driver to verify proper HW*/
  1036.     USBDInitializeDeviceProcPtr     initializeDeviceProc;        /* Proc that initializes the class driver.*/
  1037.     USBDInitializeInterfaceProcPtr     initializeInterfaceProc;    /* Proc that initializes a particular interface in the class driver.*/
  1038.     USBDFinalizeProcPtr             finalizeProc;                /* Proc that finalizes the class driver.*/
  1039.     USBDDriverNotifyProcPtr         notificationProc;            /* Proc to pass notifications to the driver.*/
  1040. };
  1041. typedef struct USBClassDriverPluginDispatchTable USBClassDriverPluginDispatchTable;
  1042. typedef USBClassDriverPluginDispatchTable * USBClassDriverPluginDispatchTablePtr;
  1043. /* Hub defines*/
  1044.  
  1045.  
  1046.  
  1047. enum {
  1048.     kUSBHubDescriptorType        = 0x29
  1049. };
  1050.  
  1051.  
  1052. enum {
  1053.                                                                 /* Hub features */
  1054.     kUSBHubLocalPowerChangeFeature = 0,
  1055.     kUSBHubOverCurrentChangeFeature = 1,                        /* port features */
  1056.     kUSBHubPortConnectionFeature = 0,
  1057.     kUSBHubPortEnablenFeature    = 1,
  1058.     kUSBHubPortSuspecdFeature    = 2,
  1059.     kUSBHubPortOverCurrentFeature = 3,
  1060.     kUSBHubPortResetFeature        = 4,
  1061.     kUSBHubPortPowerFeature        = 8,
  1062.     kUSBHubPortLowSpeedFeature    = 9,
  1063.     kUSBHubPortConnectionChangeFeature = 16,
  1064.     kUSBHubPortEnableChangeFeature = 17,
  1065.     kUSBHubPortSuspendChangeFeature = 18,
  1066.     kUSBHubPortOverCurrentChangeFeature = 19,
  1067.     kUSBHubPortResetChangeFeature = 20
  1068. };
  1069.  
  1070.  
  1071.  
  1072. enum {
  1073.     kHubPortConnection            = 1,
  1074.     kHubPortEnabled                = 2,
  1075.     kHubPortSuspend                = 4,
  1076.     kHubPortOverCurrent            = 8,
  1077.     kHubPortBeingReset            = 16,
  1078.     kHubPortPower                = 0x0100,
  1079.     kHubPortSpeed                = 0x0200
  1080. };
  1081.  
  1082.  
  1083. enum {
  1084.     kHubLocalPowerStatus        = 1,
  1085.     kHubOverCurrentIndicator    = 2,
  1086.     kHubLocalPowerStatusChange    = 1,
  1087.     kHubOverCurrentIndicatorChange = 2
  1088. };
  1089.  
  1090.  
  1091. enum {
  1092.     off                            = false,
  1093.     on                            = true
  1094. };
  1095.  
  1096.  
  1097.  
  1098. struct hubDescriptor {
  1099.                                                                 /* See usbDoc pg 250?? */
  1100.     UInt8                             dummy;                        /* to align charcteristics */
  1101.  
  1102.     UInt8                             length;
  1103.     UInt8                             hubType;
  1104.     UInt8                             numPorts;
  1105.  
  1106.     UInt16                             characteristics;
  1107.     UInt8                             powerOnToGood;                /* Port settling time, in 2ms */
  1108.     UInt8                             hubCurrent;
  1109.  
  1110.                                                                 /* These are received packed, will have to be unpacked */
  1111.     UInt8                             removablePortFlags[8];
  1112.     UInt8                             pwrCtlPortFlags[8];
  1113. };
  1114. typedef struct hubDescriptor            hubDescriptor;
  1115.  
  1116.  
  1117.  
  1118. #if PRAGMA_STRUCT_ALIGN
  1119.     #pragma options align=reset
  1120. #elif PRAGMA_STRUCT_PACKPUSH
  1121.     #pragma pack(pop)
  1122. #elif PRAGMA_STRUCT_PACK
  1123.     #pragma pack()
  1124. #endif
  1125.  
  1126. #ifdef PRAGMA_IMPORT_OFF
  1127. #pragma import off
  1128. #elif PRAGMA_IMPORT
  1129. #pragma import reset
  1130. #endif
  1131.  
  1132. #ifdef __cplusplus
  1133. }
  1134. #endif
  1135.  
  1136. #endif /* __USB__ */
  1137.  
  1138.